﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Service;
using PersonalHealth.Data.Model;
using PersonalHealth.Data.Data;
using PersonalHealth.Data.IService;
using Core.UnitOfWork;
using PersonalHealth.Data.Repository;

namespace PersonalHealth.Data.Service
{
    public class MessageBoardService : Service<MessageBoard, HealthContext>, IMessageBoardService
    {
        public IList<MessageBoard> GetLastMessageBoardInfo()
        {
            using (HealthContext context = new HealthContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                IMessageBoardRepository repository = new MessageBoardRepository(unitOfWork);

                var orderby = new Func<MessageBoard, DateTime>[] { new Func<MessageBoard, DateTime>(c => c.CreateDate) };
                var desc = new bool[] { true };
                return repository.Find<DateTime>(c => 1 == 1, orderby, desc, 1, 4);
            }
        }
    }
}
